package com.example.demo.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName IndexController
 * @Author bsy
 * @Description 简单小程序描述 秒杀场景
 * @Date 2021/12/27 23:10
 * @Version 1.0
 */

@EnableAutoConfiguration
@RestController
public class IndexController {

    @Autowired
    private StringRedisTemplate  redisTemplate;

    @RequestMapping("/index/deduceStock")
    public String deduceStock(){
        int stock = Integer.parseInt(redisTemplate.opsForValue().get("stock"));
        System.out.println("stock:"+ stock);
        return null;
    }

}
